/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2024-06-30
 * Time: 9:32
 */
public class Solution {
    public int numberOfArithmeticSlices(int[] nums) {
        int n = nums.length;
        if(n == 1){
            return 0;
        }
        int[] dp = new int[n];
        dp[0] = dp[1] = 0;
        int sum = 0;
        for (int i = 2; i < n; i++) {
            dp[i] = nums[i-1] - nums[i-2] == nums[i] - nums[i-1] ? dp[i-1] + 1 : 0;
            sum += dp[i];
        }

        return sum;
    }
}
